package com.googlecode.gwtbb.client.only.widget.basic;

import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FocusPanel;
import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Widget;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Feb 5, 2009
 */
public class NiceCheckBox extends Composite {
	FocusPanel mainPanel;
	CheckBox checkBox;
	TooltipMouseListener tooltipMouseListener;

	public NiceCheckBox() {
		this(null, false, null);
	}

	public NiceCheckBox(String label) {
		this(label, false, null);
	}

	public NiceCheckBox(String label, boolean asHtml, Widget tooltipDisplay) {
		mainPanel = new FocusPanel();
		initWidget(mainPanel);

		checkBox = new CheckBox(label, asHtml);
		mainPanel.setWidget(checkBox);

		tooltipMouseListener = new TooltipMouseListener(tooltipDisplay);
		mainPanel.addMouseListener(tooltipMouseListener);
	}

	public Widget getTooltipDisplay() {
		return tooltipMouseListener.getWidget();
	}

	public void setTooltipDisplay(Widget tooltipDisplay) {
		tooltipMouseListener.setWidget(tooltipDisplay);
	}

	public boolean isChecked() {
		return checkBox.isChecked();
	}

	public String getName() {
		return checkBox.getName();
	}

	public void setChecked(boolean checked) {
		checkBox.setChecked(checked);
	}

	public void setName(String name) {
		checkBox.setName(name);
	}
}
